package com.github.chirspan.xaas.uc.web.api;

import com.github.chirspan.xaas.api.BaseCRUDRestController;
import com.github.chirspan.xaas.core.rest.RestResult;
import com.github.chirspan.xaas.rbac.model.RbacResource;
import com.github.chirspan.xaas.rbac.service.IResourceService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Authorization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("resource")
public class RbacResourceController extends BaseCRUDRestController<RbacResource> {

    @Autowired
    private IResourceService resourceService;

    @GetMapping("/_tree")
    @ApiOperation(value = "树形资源", authorizations = {@Authorization(value = "apiKey")})
    public RestResult tree(RbacResource resource) {
        return RestResult.OK(resourceService.findResourcesTree(resource));
    }
}
